#include "ISNW_EventHandler.h"
#include "../ISNW_ScreenManager/ISNW_ScreenManager.h"
#include "../ISNW_Application.h"

using namespace ISNW;

namespace ISNW
{
	ISNW_EventHandler* g_pEventHandler = ISNW_NULL;
}

ISNW_EventHandler::ISNW_EventHandler()
{

}

ISNW_EventHandler::~ISNW_EventHandler()
{

}

ISNW_EventHandler* ISNW_EventHandler::GetPtr()
{
	static ISNW_EventHandler sInstance;
	return &sInstance;
}

ISNW_VOID ISNW_EventHandler::InitEventHandler()
{
	g_pEventHandler = GetPtr();
}

ISNW_VOID ISNW_EventHandler::DispatchCursorEvent()
{
	POINT cursor_pos;
	GetCursorPos(&cursor_pos);
	ScreenToClient(g_pApp->GetWnd(),&cursor_pos);
	g_pScreenManager->GetCurrentScreen()->ProcessCursor(cursor_pos);
}

ISNW_VOID ISNW_EventHandler::DispatchInputEvent()
{
	ISNW_InputInfo ii;
	while(g_pInput->GetFirstInput(&ii)){
		g_pScreenManager->GetCurrentScreen()->ProcessInput(ii);
		g_pInput->RemoveFirstInput();
	}
}